home *** CD-ROM | disk | FTP | other *** search
- /*________________________________________________________
-
- File: Backwash.h
-
- Header file for a printing extension that adds a
- QuickDraw picture to each page despooled.
-
- Dave Hersey
- Apple Developer Technical Support
-
- 11/11/92 - dmh - Created.
- 1/28/93 - dmh - Cleaned up for a5 seed CD.
- 3/26/93 - dmh - Updated for b1c2 (Translator changes).
- 8/24/93 - dmh - Updated for b2.
- - The picture is now rolled into the spool
- file as a resource, and applied to each
- page during despooling.
- - Added a TextEdit compatibility mode which
- strips out the white rectangles drawn by
- apps which use TextEdit to print (like
- TeachText).
- - The "intensity" panel item actually
- functions now.
- - Switched to Exception.h assertion stuff
- for error checking.
- 9/09/93 - dmh - AddBackwash now displays progress info.
- 12/18/93 - dmh - Updated for b3.
- 3/22/94 - dmh - Updated for b4.
-
- (Note: there are labels in the Mark menu.)
-
- __________________________________________________________*/
-
- #include <Types.h>
- #include <Errors.h>
- #include <Dialogs.h>
- #include <Resources.h>
- #include <ToolUtils.h>
- #include <Collections.h>
- #include <Packages.h>
- #include <String.h>
- #include <StandardFile.h>
-
- #pragma pointers_in_D0
- #include <GXExceptions.h>
- #include <GXMessages.h>
- #include <GXGraphics.h>
- #include <GXTypes.h>
- #include <GXEnvironment.h>
- #include <GXPrinting.h>
-
-
- #define kDontAddBackwash 0 /* backwash is turned on. */
- #define kAddBackwash 1 /* backwash is turned off. */
- #define kDefaultIntensity 40 /* default backwash intensity. */
-
- #define kCreator 'SpIT' /* our creator type. */
- #define kBackwashCollectionType kCreator /* our collection type. */
-
-
- /* IDs of our user settings collection item and of the
- spool file resource for our backwash picture. */
-
- #define kBackwashSettingsID gxPrintingExtensionBaseID
- #define r_BackwashPICTID gxPrintingExtensionBaseID +1
-
- #define r_BackwashPanel 6000 /* our panel ID. */
-
- #define d_Intensity 5 /* intensity of image. */
- #define d_SelectPicture 7 /* "Select picture" button. */
- #define d_FileNameItem 9 /* DITL item for filename to load. */
-
- #define r_BackwashStatus 1000 /* Our 'DLOG', 'DITL', and 'STR#' */
- /* resources for displaying mssgs. */
-
- #define d_StatusFieldItem 1 /* DITL item for dialog text field.*/
-
- #define s_StatusLoadPict 1 /* Indices to different status' */
- #define s_ConvertPict 2 /* messages in our STR# resource. */
- #define s_SetShapeIntensity 3
- #define s_SpoolShapeResource 4
- #define s_PictureNotLoaded 5
-
- #define n_dlogLevel .25 /* Level to display our dialogs at as a */
- /* percentage of the way down the */
- /* screen. (See PositionWindow.) */
-
-
- // This is what our collection looks like. Notice the offsets below
- // agree with what we've said in our 'xdtl' resource. This MUST be
- // the case.
-
- typedef struct BackwashCollection
- { // offset:
- long intensity; // 0 brightness %
- unsigned char addBackwash; // 4 is user adding a backwash?
- unsigned char useTextEditMode;// 5 use TextEdit compatibility mode?
- // (See routine RemoveWhiteRects.)
- Boolean haveFileInfo; // file chosen?
- FSSpec fileInfo; // info about the file chosen.
- } BackwashCollection;
-
-
- // This structure is used by the ShapeToHandle and HandleToShape routines.
-
- typedef struct UserSpool
- {
- gxSpoolBlock spool; // struct passed to gxFlattenShape & gxUnflattenShape.
- long position; // byte offset in handle for next read or write.
- long size; // handle size.
- void *data; // the handle we're working with.
- } UserSpool;
-
-
- #define kAllocationIncrement (40L *1024L) /* Initial handle size for flattened shape. */
-
-
- // This structure holds the instance-global data.
- typedef struct MyData
- {
- gxShape backwashShape;
- } MyDataRec, *MyDataPtr, **MyDataHdl ;
-
-
- // Function prototypes:
-
- void MyInitDataHandle(MyDataHdl dataHandle);
- gxShape GetBackwashShape(void) ;
- OSErr BWInitialize(void);
- OSErr BWShutDown(void);
- OSErr BWJobPrintDialog(gxDialogResult *dlogResult);
- OSErr BWHandlePanelEvent(gxPanelInfoRecord *panelInfo);
- OSErr BWCreateSpoolFile(FSSpecPtr anFSSpec, long createOptions,
- gxSpoolFile *theSpoolFile);
- OSErr BWCloseSpoolFile(gxSpoolFile theSpoolFile, long closeOptions);
- OSErr BWDespoolPage(gxSpoolFile theSpoolFile, long thePageNum,
- gxFormat theFormat, gxShape *thePage,
- Boolean *formatChanged);
- OSErr InitGlobalData(void);
- OSErr SetUpPrintPanel(void);
- void OpenBackwashPanel(DialogPtr pDlg, short itemCount);
- PicHandle LoadAPict(FSSpecPtr opFSSpec);
- gxGraphicsError AddBackwash(FSSpecPtr fileInfo, short theIntensity,
- gxSpoolFile theSpoolFile);
- gxGraphicsError SetShapeIntensity(gxShape theShape, short theIntensity);
- Boolean RemoveWhiteRects(gxShape theShape);
- OSErr GetJobCollectionItem(void *collectItem, long *collectSize,
- OSType collectType, short collectID);
- gxGraphicsError HandleSpoolProc(gxSpoolCommand command, UserSpool *block);
- Handle ShapeToHandle(gxShape source);
- gxShape HandleToShape(Handle source, long count, const gxViewPort portList[]);
- void PositionWindow(WindowPtr windPtr, Boolean showIt, float vertPercent);
-